<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>把类当成特殊函数</title>
</head>
<body>
  <script>
    class Person {}

    let p1 = new Person();

    console.log(p1.constructor === Person);  // true
    console.log(p1 instanceof Person);  // true
    console.log(p1 instanceof Person.constructor);  // false

    let p2 = new Person.constructor();

    console.log(p2.consturctor === Person);  // false
    console.log(p2 instanceof Person);  // false
    console.log(p2 instanceof Person.constructor);  // true
  </script>

  <script>
    let p = new class Foo {
      constructor(x) {
        console.log(x);
      }
    }('bar');

    console.log(p);  // Foo {}
  </script>
</body>
</html>